package com.company.network.cominterceptor;

import com.company.network.base.INetWorkRequestInfo;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

public class ComReqInterceptor implements Interceptor {

    private final INetWorkRequestInfo requestInfo;

    public ComReqInterceptor(INetWorkRequestInfo requestInfo) {
        this.requestInfo = requestInfo;
    }

    @Override
    public Response intercept(Chain chain) throws IOException {
        String timeStr = String.valueOf(System.currentTimeMillis());
        Request.Builder builder = chain.request().newBuilder();
        builder.addHeader("os", "android");
        builder.addHeader("appVersion", requestInfo.getAppVersionName());
        builder.addHeader("date", timeStr);
        return chain.proceed(builder.build());
    }
}
